#include "common.h"


int make_nonblock(int fd){
    int flag = fcntl(fd, F_GETFL);
    if(flag < 0){
        return -1;
    }
    flag |= O_NONBLOCK;
    return fcntl(fd, F_SETFL, flag);
}

int make_block(int fd){
    int flag = fcntl(fd, F_GETFL);
    if(flag < 0){
        return -1;
    }
    flag &= ~O_NONBLOCK;
    return fcntl(fd, F_SETFL, flag);
}